package com.bolt.support.spring.jpa.jpql;

import com.bolt.convention.data.PageInfo;
import com.bolt.support.query.conditions.domain.SqlClause;
import com.bolt.support.spring.jpa.entity.PersistableEntity;
import org.springframework.data.domain.Pageable;

import java.util.List;
import java.util.function.Consumer;

public interface JPQLQuery<T> {

    <T>JPQLQuery <T> select(Class <T> type, SqlClause... clauses);

    <T>JPQLQuery <T> selectAll(Class <T> type, SqlClause... clauses);

    <T> JPQLQuery <T> selectDistinct(Class <T> type, SqlClause... clauses);

    <T>JPQLQuery <T> select(SqlClause... clauses);

    <T> JPQLQuery <T> selectDistinct(SqlClause... clauses);

    JPQLQuery <T> from(EntityClause... sources);

    <T extends PersistableEntity> JPQLQuery <T> from(Class<T> type);

    JPQLQuery <T> leftJoin(EntityClause target);

    JPQLQuery <T> rightJoin(EntityClause target);

    JPQLQuery <T> innerJoin(EntityClause target);

    JPQLQuery <T> fullJoin(EntityClause target);

    JPQLQuery <T> on(SqlClause... columns);

    JPQLQuery <T> where(CompareClause clause);

    JPQLQuery <T> where();

    JPQLQuery <T> where( Consumer<CompareClause> consumer);


    JPQLQuery <T> groupBy(SqlClause... target);

    JPQLQuery <T> orderBy(SqlClause... target);

    JPQLQuery <T> having(CompareClause clause);

    JPQLQuery <T> limit(long limit);

    JPQLQuery <T> offset(long offset);

    JPQLQuery <T> and(Ops ops,ColumnClause... clause);

    JPQLQuery <T> and(String exprs,Ops ops,ColumnClause... clause);

    JPQLQuery <T> and(CompareClause... compareClause);

    JPQLQuery <T> or(Ops ops,ColumnClause... clause);

    JPQLQuery <T> or(String exprs,Ops ops,ColumnClause... clause);

    JPQLQuery <T> or(CompareClause... compareClause);

    JPQLQuery <T>  buildCondition(Object parameterObject);

    //列转行
    JPQLQuery <T>  unpivot(String transformColumns,String columnsLabels);
    //行转列
    JPQLQuery <T>  pivot(Object parameterObject);

    List <T> fetch();

    T fetchOne();

    T fetchFirst();

    long fetchCount();

    PageInfo<T> fetchPage(Pageable pageable);

    JPQLQuery <T> setHint(String name, Object value);

    JPQLQuery <T> usedSubCount(boolean used);


}

 